using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using UnityEngine;

public class settings : MonoBehaviour
{
	public enum typeStore
	{
		PlayStore = 0,
		AmazonStore = 1
	}

	public enum MainCameraType
	{
		TPSCamera = 0,
		RPGCamera = 1,
		FPSCamera = 2
	}

	public const string PublicKeyApp = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqsXnLbQdmJI/MvDCtO+Z6/uvUMDfjFzlMfRE5O2o53p4QMEBSmKs3T9OW/5tta2BMHMlt4f2r6uj7KJYh93lgdkSjDMSDsk+ryG6865wsSukASUQamzXS0VFZjBwLqK9qTW6TS8KdeMLNGxQmgK4WQqV0+b+oW4n2T6UoCnX7JQegeCgtEt0mrg0cPk4kW1bfPKr11V2lPfnjBepUIpX9GSoPGXuYPAHVfxVDp0d9N3fhv8eLjhVMvM3kpr4hYD4gWxBkOQDkZ+m2jJFi/zdUehKyTqLvwm4PAPL1wL3GAkb3dfAh3ZgeflQ2ZbB8JEDy3/QK+4aveV/DbRPVTFVVwIDAQAB";

	public const string PublicKeyAppXML = "<RSAKeyValue><Modulus>qsXnLbQdmJI/MvDCtO+Z6/uvUMDfjFzlMfRE5O2o53p4QMEBSmKs3T9OW/5tta2BMHMlt4f2r6uj7KJYh93lgdkSjDMSDsk+ryG6865wsSukASUQamzXS0VFZjBwLqK9qTW6TS8KdeMLNGxQmgK4WQqV0+b+oW4n2T6UoCnX7JQegeCgtEt0mrg0cPk4kW1bfPKr11V2lPfnjBepUIpX9GSoPGXuYPAHVfxVDp0d9N3fhv8eLjhVMvM3kpr4hYD4gWxBkOQDkZ+m2jJFi/zdUehKyTqLvwm4PAPL1wL3GAkb3dfAh3ZgeflQ2ZbB8JEDy3/QK+4aveV/DbRPVTFVVw==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";

	public const typeStore currentStore = typeStore.PlayStore;

	public const int currentVersionGame = 17;

	public const int tierCount = 7;

	public static string verConnectPhoton = "GTA_ANDROID_6.7.5";

	public static bool isNewPvpPanelEnabled = true;

	public static settings thisScript;

	public static string keyVersionGame = "keyVersionGame";

	public static bool learningCompleted = true;

	public static bool includePreloadingSectors = true;

	public static string shopTextureFolderPath = "AtlasShopGuns/";

	public static bool loadFromGame;

	public static TypeControlCar typeControlerCar = TypeControlCar.button;

	public static bool rotatePlayerOnTarget = true;

	public static string keyEnableShadow = "keyEnableShadow";

	public static string keyTypeControlCar = "keyTypeControlCar";

	public static string keyTutorialActive = "keyTutorialActiveNew";

	public static string keyCryptoTutorialActive = "keyCryptoTutorialActive";

	public static string keyEnterPassword = "keyEnterPassword";

	public static string keyShooseSkin = "keyShooseSkin";

	public static string keyName = "keyName";

	public static string keyCryptoName = "keyCryptoName";

	public static string keyRoomPass = "keyRoomPass";

	public static string keyRoomName = "keyRoomName";

	public static string keyOfflineMode = "keyOfflineMode";

	public static string keyCurExperience = "keyCurExperience";

	public static string keyCurLevel = "keyCurLevel";

	public static string keyInfoAfterTutorial = "keyInfoAfterTutorial";

	public static string keyShowLevelAfterTutorial = "keyShowLevelAfterTutorial";

	public static string keyRuleLic = "keyRuleLic";

	public static string keySensivity = "keySensivity";

	public static string keyLoadPVPMenu = "keyLoadPVPMenu";

	public static string keyMaxCountPVPKills = "keyMaxCountPVPKill";

	public static string keyObtainedDollars = "keyObtainedDollars";

	public static string keyObtainedGold = "keyObtainedGold";

	public static string keyNameArea = "keyNameArea";

	public static string keyForShowLoadingSprite = "keyForShowLoadingSprite";

	public static string keyHowTakeMoneyFreePlay = "keyHowTakeMoneyFreePlay";

	public static string keyHowTakeMoneyOnline = "keyHowTakeMoneyOnline";

	public static string keyKolDead = "keyKolDead";

	public static string keyKolKill = "keyKolKill";

	public static string keyKolMaxPoints = "keyKolMaxPoints";

	public static string keyKolCoins = "keyKolCoins";

	public static string keyMonetBCount = "keyMonetBCount";

	public static string keyArmor = "keyArmor";

	public static string keyEquipArmor = "keyEquipArmor";

	public static string keyKeychainArmor = "keyKeychainArmor";

	public static string keyArmorEnabled = "keyArmorEnabled";

	public static string keyEquipGun = "EquipGun_";

	public static string keyKeychainKolCoins = "keyKeychainKolCoins";

	public static string keyKeychainGun1 = "keyKeychainGun1";

	public static string keyKeychainGun2 = "keyKeychainGun2";

	public static string keyKeychainGun3 = "keyKeychainGun3";

	public static string keyKeychainGunBat = "keyKeychainGunBat";

	public static string keyKeychainGunSniper = "keyKeychainGunSniper";

	public static string keyKeychainGunMinigun = "keyKeychainGunMinigun";

	public static string keyKeychainJetpack = "keyKeychainJetpack";

	public static string keyKeychainSpas12 = "keyKeychainSpas12";

	public static string keyKeychainBrass = "keyKeychainBrass";

	public static string keyKeychainRevolver = "keyKeychainRevolver";

	public static string keyKeychainKnife = "keyKeychainKnife";

	public static string keyKeychainChainsaw = "keyKeychainChainsaw";

	public static string keyKeychainGlock = "keyKeychainGlock";

	public static string keyCountBullets = "keyCountBullets_";

	public static string keyBulletsSaved = "keyBulletsSaved_";

	public static string keyLevelUp = "IsLevelUp";

	public static string keyTimeStartNewUser = "TimeStartNewUser";

	public static string keyArrAllWeapons = "keyArrAllWeapons";

	public static string keyBuyGunUzi = "SMG";

	public static string keyBuyGunShotgun = "shotgun";

	public static string keyBuyGunAk47 = "ak47";

	public static string keyBuyGunSniperRifle = "SniperRifle";

	public static string keyBuyGunBat = "bat";

	public static string keyBuyGunMinigun = "Minigun";

	public static string keyBuyGunGrenade = "grenade";

	public static string keyBuyGunMolotov = "molotov";

	public static string keyBuyGunMolotovPatrick = "molotovPatrick";

	public static string keyBuyInvisible = "Invisible";

	public static string keyCountItem = "keyCountItem";

	public static string keySavedConsumable = "keySavedConsumable";

	public static string KEY_ROCKET_LEAGUE_PING_LIMIT = "rocket_league_ping_limit";

	public static string keyBuyGunC4 = "c4";

	public static string keyBuyGunMine = "Mine";

	public static string keyBuyRevolver = "Revolver";

	public static string keyBuyKnife = "Knife";

	public static string keyBuyEasterGrenade = "easterGrenade";

	public static string keyBuyEasterGrenade_v2 = "easterGrenade_v2";

	public static string keyBuyChainsaw = "Chainsaw";

	public static string keyBuyGlock = "glock18";

	public static string keyBuySpas12 = "SPAS12";

	public static string keyBuyBrass = "Brass_knuckles";

	public static string keyBuyElectroshock = "Electroshock";

	public static string keyBuyFlamethrower = "flamethrower";

	public static string keyBuyThompson = "thompson";

	public static string keyBuyRPG = "rpg";

	public static string keyBuyICS_190_GLM = "ICS_190_GLM";

	public static string keyDonatePlayer = "DonatePlayer";

	public static string keyLastPaymentDate = "LastPayment";

	public static string keyLastPayment = "LastPaymentFloat";

	public static string keyPayment = "PayingUser";

	public static string keyBuyingCash = "BuyingCash";

	public static string keyBuyingGold = "BuyingGold";

	public static string KeyFirsPurchasedCash = "FirsPurchasedCash";

	public static string KeyFirsPurchasedGold = "FirsPurchasedGold";

	public static string KeyActionAfterTutor = "ActionAfterTutor";

	public static string KeyTopUsedWeaponName = "TopUsedWeaponName";

	public static string KeyTopUsedWeaponCount = "TopUsedWeaponCount";

	public static string keyStartSesionTime = "StartSesionTime";

	public static string keyCollectedCashOnLevel = "CollectedCashOnLevel";

	public static string keyDonateCashOnLevel = "DonateCashOnLevel";

	public static string KeyLastGameMode = "LastGameMode";

	public static string KeyLastMap = "KeyLastMap";

	public static string keyAllPayments = "AllPayments";

	public static string keySelectScene = "keySelectScene";

	public static string keyAllSpentCash = "AllSpentCash";

	public static string keyAllEarnedCash = "AllEarnedCash";

	public static string keyReputationPoints = "ReputationPoints";

	public static string keyCurrentReputationLevel = "CurrentReputationLevel";

	public static string keyAchievedNewReputation = "AchievedNewReputation";

	public static string keyPVPKills = "PVPKills";

	public static string keyPVPWins = "PVPWins";

	public static string keySandboxKills = "SandboxKills";

	public static string keySandboxWins = "SandboxWins";

	public static string keyDestroyedOnlineCars = "DestroyedOnlineCars";

	public static string keyDestroyedOnlineTanks = "DestroyedOnlineTanks";

	public static string keyDestroyedOnlineHelicopters = "DestroyedOnlineHelicopters";

	public static string keyDestroyedOnlineBoats = "DestroyedOnlineBoats";

	public static string keyDestroyedOnlineBikes = "DestroyedOnlineBikes";

	public static string keyDestroyedOfflineCars = "DestroyedOfflineCars";

	public static string keyDestroyedOfflineTanks = "DestroyedOfflineTanks";

	public static string keyDestroyedOfflineHelicopters = "DestroyedOfflineHelicopters";

	public static string keyDestroyedOfflineBoats = "DestroyedOfflineBoats";

	public static string keyDestroyedOfflineBikes = "DestroyedOfflineBikes";

	public static string keyKilldOfflineCops = "KilldOfflineCops";

	public static string keyKilldOfflineCitizens = "KilldOfflineCitizens";

	public static string keyKilldOfflineBandits = "KilldOfflineBandits";

	public static string keyKilldOfflineZombies = "KilldOfflineZombies";

	public static string keyTotalTimePlayed = "TotalTimePlayed";

	public static Dictionary<string, int> consumableDictinary = new Dictionary<string, int>();

	private Dictionary<TypeGame, BaseGameModSettings> gameModSettings = new Dictionary<TypeGame, BaseGameModSettings>();

	public static string noNamePlayer = "No name";

	public static string keyRandomNickName = "keyRandomNickName";

	public static string keyIdPlayer = "keyIdPlayer";

	public static string idPlayer = string.Empty;

	public static int placePlayerPVE = -1;

	public static int placePlayerPVP = -1;

	public static int placePlayerREP = -1;

	public static string keyWeekCountKillPVE = "keyWeekCountKillPVE";

	public static string keyWeekCountKillPVP = "keyWeekCountKillPVP";

	public static string keyMyWeekScorePVE = "keyMyWeekScorePVE";

	public static string keyMyWeekScorePVP = "keyMyWeekScorePVP";

	public static string keyWeekReputation = "keyWeekReputation";

	public static string keyMyWeekScoreReputation = "keyMyWeekScoreReputation";

	public static string keyCamActive = "keyCamActive";

	public static int maxKolBonuse = 25;

	public static int maxKolGunBonuse = 0;

	public static int tekKolBonuse = 0;

	public static int kolStarOnLevel = 10;

	public static float timeGame = 420f;

	public static int tekKolDead = 0;

	public static int tekKolKillPVE = 0;

	public static int tekKolKillPVP = 0;

	public static float speedCarForIgnoreEnemy = 2f;

	public static float speedCarForHighDemageEnemy = 60f;

	public static string keyForBuySkin = "keyForBuySkin_";

	public static int tekNomSkin = 0;

	public static string tekName = "Player";

	public static int cathcedExeptionstForLabels = 0;

	public static int cathedExeptionsForFlurry = 0;

	public static int cathedWarningstForFlurry = 0;

	private static SaveInt saveCatchedExeptions;

	private static bool needSaveExeptionsToStorager = false;

	public static int cathedWarningsForLabels = 0;

	private static SaveInt saveCathedWarnings;

	private static bool needSaveCathedWarningsToStorager = false;

	public static float jetpackFuel;

	public static bool testBuilding = false;

	private static bool _offlineMode = false;

	public static int maxKolVragov;

	public static int tekKolVragov = 0;

	public static float lodSectorRadiusKoef = 1f;

	public AudioClip soundButton;

	public AudioClip soundChangeMoney;

	public static bool isConnected = false;

	public static int inComingMessagesCounter = 0;

	public static HashSet<string> unimportantRPCList = new HashSet<string> { "SimpleShoot", "ActivateJetpack", "EnableJetpackParticle", "animDropAfterFlyDownOnline", "SimpleReload" };

	public static HashSet<string> importantRPCList = new HashSet<string>
	{
		"AskRespawnIndexRPC", "RecieveRespawnIndexRPC", "addMessageToList", "addMessageWinner", "GetInCarWithConfirmation", "GetOutOfCar", "HideCarOnline", "Kill", "ResetCarWithDelayOnline", "StartTimerOnline",
		"wakeUpAfterCar", "highDamageCar", "lowDamageCar", "StopDrive", "TimeOut", "AskGetInCar", "NotifyRaceEnded", "StartCheckAnimationMove", "CrushOnCar", "Crush",
		"ShowGetOutOfCarAnim", "reset", "CircleRPC", "CheckPointRPC", "SetTeam", "SendTeamToPlayer", "ResetThemAll", "SetPointFromMaster", "RocketLeagueGoalRPC", "SetRespawnTime",
		"ResetCarRPC", "GetDamage", "SwitchFlag", "SwitchInterface", "SendInfo", "ConnectNewPlayer", "PixelmonCaught", "PlayerCatchPixelmon", "SendMasterCapturedPixelmon", "CapturedPixelmon",
		"ApplyCarUpgradesRPC", "EndPixelmonRound", "SendMasterMyTeam", "RespawnCRGateRPC"
	};

	private string keyNewSaveNickName = "keyNewSaveNickName";

	private static string leftHandControlKey = "LeftHandControlKey";

	public static bool seichasPokupaemInapi = false;

	public double savedPlayTime;

	public static float Sensivity3DTouch
	{
		get
		{
			if (PlayerPrefs.HasKey("Sensivity3DTouch"))
			{
				return PlayerPrefs.GetFloat("Sensivity3DTouch");
			}
			return 0.5f;
		}
		set
		{
			PlayerPrefs.SetFloat("Sensivity3DTouch", value);
		}
	}

	public static string RaceCarName
	{
		get
		{
			string text = BCWStorage.Get<string>("RaceCarName");
			if (string.IsNullOrEmpty(text))
			{
				text = "_car_dodje_ChelendjerRace";
			}
			return text;
		}
		set
		{
			BCWStorage.Set("RaceCarName", value);
		}
	}

	public static string SelectedTankName
	{
		get
		{
			string text = BCWStorage.Get<string>("SelectedTankName");
			if (string.IsNullOrEmpty(text))
			{
				text = "_car_tank_leopardFree";
			}
			return text;
		}
		set
		{
			BCWStorage.Set("SelectedTankName", value);
		}
	}

	public static string SelectedTitanName
	{
		get
		{
			string text = BCWStorage.Get<string>("SelectedTitanName");
			if (string.IsNullOrEmpty(text))
			{
				text = "Titanic_02";
			}
			return text;
		}
		set
		{
			BCWStorage.Set("SelectedTitanName", value);
		}
	}

	public static bool shoot3DtouchDisabled
	{
		get
		{
			return BCWStorage.Get<bool>("shoot3Dtouch_disabled");
		}
		set
		{
			BCWStorage.Set("shoot3Dtouch_disabled", value);
		}
	}

	public static int CathedExeptions
	{
		get
		{
			return saveCatchedExeptions;
		}
		set
		{
			if (settings.OnChangeExeptionsAmount != null)
			{
				settings.OnChangeExeptionsAmount();
			}
			if (value - (int)saveCatchedExeptions > 0 && GameController.instance != null && GameController.instance.curTypeGame == TypeGame.normal)
			{
				cathedExeptionsForFlurry += value - (int)saveCatchedExeptions;
			}
			saveCatchedExeptions = value;
			needSaveExeptionsToStorager = true;
			cathcedExeptionstForLabels = value;
			if ((bool)MoneyPanelController.instance)
			{
				MoneyPanelController.instance.UpdateLabels();
			}
			if (VolumeController.IsSoundEnable)
			{
				NGUITools.PlaySound(thisScript.soundChangeMoney);
			}
		}
	}

	public static int CathedWarnings
	{
		get
		{
			SaveCathedExeptionsToStorager();
			return saveCathedWarnings;
		}
		set
		{
			if (settings.OnChangeExeptionsAmount != null)
			{
				settings.OnChangeExeptionsAmount();
			}
			if (value - (int)saveCathedWarnings > 0 && GameController.instance != null && GameController.instance.curTypeGame == TypeGame.normal)
			{
				cathedWarningstForFlurry += value - (int)saveCathedWarnings;
			}
			cathedWarningsForLabels = value;
			saveCathedWarnings = value;
			needSaveCathedWarningsToStorager = true;
			if ((bool)MoneyPanelController.instance)
			{
				MoneyPanelController.instance.UpdateLabels();
			}
		}
	}

	public static bool offlineMode
	{
		get
		{
			return _offlineMode;
		}
		set
		{
			if (value != _offlineMode)
			{
				_offlineMode = value;
				if (settings.gameModeChange != null)
				{
					settings.gameModeChange();
				}
			}
		}
	}

	public static int WeekCountKillPVE
	{
		get
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekCountKillPVE))
			{
				return Load.LoadInt(keyWeekCountKillPVE);
			}
			ProtectedPrefs.SaveInt(keyWeekCountKillPVE, 0);
			return 0;
		}
		set
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekCountKillPVE))
			{
				ProtectedPrefs.SaveInt(keyWeekCountKillPVE, value);
			}
			else
			{
				ProtectedPrefs.SaveInt(keyWeekCountKillPVE, 0);
			}
		}
	}

	public static int WeekCountKillPVP
	{
		get
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekCountKillPVP))
			{
				return Load.LoadInt(keyWeekCountKillPVP);
			}
			ProtectedPrefs.SaveInt(keyWeekCountKillPVP, 0);
			return 0;
		}
		set
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekCountKillPVP))
			{
				ProtectedPrefs.SaveInt(keyWeekCountKillPVP, value);
			}
			else
			{
				ProtectedPrefs.SaveInt(keyWeekCountKillPVP, 0);
			}
		}
	}

	public static int WeekReputation
	{
		get
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekReputation))
			{
				return Load.LoadInt(keyWeekReputation);
			}
			ProtectedPrefs.SaveInt(keyWeekReputation, 0);
			return 0;
		}
		set
		{
			if (ProtectedPrefs.CryptoKeyIntCorrect(keyWeekReputation))
			{
				ProtectedPrefs.SaveInt(keyWeekReputation, value);
			}
			else
			{
				ProtectedPrefs.SaveInt(keyWeekReputation, 0);
			}
		}
	}

	public static bool LeftHandControlEnable
	{
		get
		{
			if (!PlayerPrefs.HasKey(leftHandControlKey))
			{
				return false;
			}
			return PlayerPrefs.GetInt(leftHandControlKey) > 0;
		}
		set
		{
			if (LeftHandControlEnable != value)
			{
				PlayerPrefs.SetInt(leftHandControlKey, value ? 1 : 0);
				PlayerPrefs.Save();
			}
		}
	}

	public static event Action OnChangeExeptionsAmount;

	public static event Action gameModeChange;

	public static string GetPackageNameByStore(typeStore store)
	{
		switch (store)
		{
		case typeStore.PlayStore:
			return "block.app.wars";
		case typeStore.AmazonStore:
			return "com.block.wars";
		default:
			return "qwe.qwe.sdd";
		}
	}

	public static string GetSelectedTransportName(GameModesUI.TransportType type)
	{
		switch (type)
		{
		case GameModesUI.TransportType.car:
			return RaceCarName;
		case GameModesUI.TransportType.tank:
			return SelectedTankName;
		case GameModesUI.TransportType.titan:
			return SelectedTitanName;
		default:
			return null;
		}
	}

	public static int DayToSeconds(int days)
	{
		return MinutesToSeconds(days * 24);
	}

	public static int HoursToSeconds(int hours)
	{
		return MinutesToSeconds(hours * 60);
	}

	public static int MinutesToSeconds(int minutes)
	{
		return minutes * 60;
	}

	public static void SetSelectedTransportName(GameModesUI.TransportType type, string transportName)
	{
		switch (type)
		{
		case GameModesUI.TransportType.car:
		{
			ProductCar productCar = (ProductCar)MarketController.Instance.GetProduct(transportName);
			if (!productCar.notForRace)
			{
				RaceCarName = transportName;
			}
			break;
		}
		case GameModesUI.TransportType.tank:
			SelectedTankName = transportName;
			break;
		case GameModesUI.TransportType.titan:
			SelectedTitanName = transportName;
			break;
		}
	}

	public static void SetAreaNameForRespawn(string key, bool clearSpriteName = true)
	{
		BCWStorage.Set(keyNameArea, key);
		if (clearSpriteName)
		{
			BCWStorage.Set(keyForShowLoadingSprite, key);
		}
	}

	public static void SetAreaNameForLoading(string keyLoadingImage)
	{
		BCWStorage.Set(keyForShowLoadingSprite, keyLoadingImage);
	}

	public static BaseGameModSettings GetSettings(TypeGame type)
	{
		if (!thisScript.gameModSettings.ContainsKey(type))
		{
			string path = string.Empty;
			switch (type)
			{
			case TypeGame.Zombe:
				path = "Settings/ZombeSettings";
				break;
			case TypeGame.CopsAndRobbers:
				path = "Settings/CRSettings";
				break;
			}
			thisScript.gameModSettings.Add(type, Resources.Load<BaseGameModSettings>(path));
		}
		return thisScript.gameModSettings[type];
	}

	public static void ShowSpecialLabelWithAnimation(int amount, Vector3 startPosition, bool worldToUI)
	{
		IncreaseExeptions(amount);
		if (amount > 4000)
		{
			amount = 4000;
		}
		if ((bool)FlyingPointsController.instance && !Application.loadedLevelName.Equals("Tutorial"))
		{
			FlyingPointsController.instance.AddFlyingPointsByAmount(startPosition, PointsType.Cash, amount, worldToUI);
		}
	}

	public static void IncreaseExeptions(int amount)
	{
		CathedExeptions += amount;
		SaveCathedExeptionsToStorager();
	}

	public static IEnumerator ShowSpecialLabelWithAnimationDelayd(int amount, Transform startTransform, bool worldToUI)
	{
		yield return null;
		yield return null;
		ShowSpecialLabelWithAnimation(amount, startTransform.position, worldToUI);
	}

	public static IEnumerator ShowLabelWithAnimationDelayd(int amount, Transform startTransform, bool worldToUI)
	{
		yield return null;
		yield return null;
		ShowLabelWithAnimation(amount, startTransform.position, worldToUI);
	}

	public static void ShowLabelWithAnimation(int amount, Vector3 startPosition, bool worldToUI)
	{
		IncreaseWarnings(amount);
		if (amount > 10)
		{
			amount = 10;
		}
		FlyingPointsController.instance.AddFlyingPointsByAmount(startPosition, PointsType.Gold, amount, worldToUI);
	}

	public static void IncreaseWarnings(int amount)
	{
		CathedWarnings += amount;
		SaveCathedExeptionsToStorager();
	}

	private static void SaveExeptionsToStorager(int catchedExeptions)
	{
		if (needSaveExeptionsToStorager)
		{
			int num = catchedExeptions - BCWStorage.Get<int>(keyKolCoins);
			if (num > 0)
			{
				int num2 = BCWStorage.Get<int>(keyAllEarnedCash);
				num2 += num;
				BCWStorage.Set(keyAllEarnedCash, num2, true);
			}
			else if (num < 0)
			{
				int num3 = BCWStorage.Get<int>(keyAllSpentCash);
				num3 -= num;
				BCWStorage.Set(keyAllSpentCash, num3, true);
			}
			BCWStorage.Set(keyKolCoins, catchedExeptions, true);
			Save.SaveInt(keyCollectedCashOnLevel, catchedExeptions);
			needSaveExeptionsToStorager = false;
		}
	}

	private static void SaveCathedWarningsToStorager(int cathedWarnings)
	{
		if (needSaveCathedWarningsToStorager)
		{
			BCWStorage.Set(keyMonetBCount, cathedWarnings, true);
			needSaveCathedWarningsToStorager = false;
		}
	}

	public static void SaveCathedExeptionsToStorager()
	{
		SaveExeptionsToStorager(saveCatchedExeptions);
		SaveCathedWarningsToStorager(saveCathedWarnings);
		PlayerPrefs.Save();
	}

	private void Awake()
	{
		thisScript = this;
		isConnected = false;
		Application.targetFrameRate = 30;
		typeControlerCar = BtnTypeControlCar.ConvertIntToTypeControl(Load.LoadInt(keyTypeControlCar));
		PhotonNetwork.CacheSendMonoMessageTargets(PhotonNetwork.SendMonoMessageTargetType);
		if (Device.indexWeakDevice > 0)
		{
			maxKolVragov = 8;
		}
		else
		{
			maxKolVragov = 16;
		}
		BCWDebug.Log("MoneyLoaded", "InApp");
		saveCatchedExeptions = BCWStorage.Get<int>(keyKolCoins);
		saveCathedWarnings = BCWStorage.Get<int>(keyMonetBCount);
		if (!BCWStorage.Get<bool>("goldDevolvated"))
		{
			saveCathedWarnings = (int)saveCathedWarnings * 10;
			BCWStorage.Set(keyMonetBCount, (int)saveCathedWarnings, true);
			BCWStorage.Set("goldDevolvated", true, true);
		}
		int num = Load.LoadInt(keyVersionGame);
		if (BCWDebug.isDebugBuild)
		{
			BCWDebug.Log("installedVersion == " + num + " currentVersionGame=" + 17);
		}
		if (num < 17)
		{
			if (num <= 1)
			{
				Storager.createInt(0, keyKeychainKolCoins);
				Storager.createInt(0, keyKeychainGun1);
				Storager.createInt(0, keyKeychainGun2);
				Storager.createInt(0, keyKeychainGun3);
				Storager.createInt(0, keyKeychainGunBat);
				Storager.createInt(0, keyKeychainGunSniper);
				Save.SaveInt(keyShooseSkin, 0);
				Save.SaveBool(keyOfflineMode, false);
				Save.SaveInt(keyKolDead, 0);
				Save.SaveInt(keyKolKill, 0);
				Save.SaveInt(keyKolMaxPoints, 0);
			}
			if (num <= 2)
			{
				Storager.createInt(0, keyKeychainGunMinigun);
				Save.SaveInt(keyShooseSkin, 0);
			}
			if (num <= 3)
			{
				Storager.createInt(0, keyKeychainGunSniper);
			}
			if (num <= 6)
			{
				Storager.createBool(false, keyKeychainRevolver);
				Storager.createBool(false, keyKeychainChainsaw);
				Storager.createBool(false, keyKeychainKnife);
			}
			if (num <= 7)
			{
				Storager.createBool(false, keyKeychainGlock);
			}
			if (num <= 10)
			{
				Storager.createBool(false, keyKeychainSpas12);
				Storager.createBool(false, keyKeychainBrass);
			}
			if (num <= 12)
			{
				Storager.createBool(false, keyBuyElectroshock);
				Storager.createBool(false, keyBuyFlamethrower);
				Storager.createBool(false, keyBuyThompson);
				Storager.createBool(false, keyBuyRPG);
			}
			if (num <= 13)
			{
				Storager.createBool(false, keyBuyICS_190_GLM);
			}
			if (num <= 14)
			{
				Storager.createInt(0, keyMonetBCount);
			}
			if (num <= 15)
			{
				WeekCountKillPVE = 0;
				WeekCountKillPVP = 0;
			}
			if (num <= 17)
			{
				VolumeController.VolumeMusic = 1f;
				VolumeController.VolumeSound = 1f;
			}
			Save.SaveInt(keyVersionGame, 17);
			BCWStorage.Set(keyVersionGame, 17);
		}
		updateArmorEnabled();
		learningCompleted = true;
		tekNomSkin = Load.LoadInt(keyShooseSkin);
		if (!BCWStorage.Get<bool>(keyNewSaveNickName))
		{
			string text = Load.LoadString(keyName);
			if (text != "Player")
			{
				BCWStorage.Set(keyCryptoName, text);
			}
			BCWStorage.Set(keyNewSaveNickName, true);
		}
		tekName = BCWStorage.Get<string>(keyCryptoName);
		tekKolDead = Load.LoadInt(keyKolDead);
		tekKolKillPVE = Load.LoadInt(keyKolKill);
		tekKolKillPVP = Load.LoadInt(keyKolMaxPoints);
		cathedWarningsForLabels = CathedWarnings;
		cathcedExeptionstForLabels = CathedExeptions;
		offlineMode = Load.LoadBool(keyOfflineMode);
	}

	public static void UpdateIdPlayer()
	{
		if (!ProtectedPrefs.CryptoKeyStringCorrect(keyIdPlayer))
		{
		}
		idPlayer = Load.LoadString(keyIdPlayer);
	}

	public static void updateOfflineMode(bool val)
	{
		offlineMode = val;
		Save.SaveBool(keyOfflineMode, val);
	}

	public static void updateKolCoins(int coins)
	{
		CathedExeptions = coins;
		Save.SaveInt(keyKolCoins, coins);
		Save.SaveInt(keyCollectedCashOnLevel, coins);
		if (VolumeController.IsSoundEnable)
		{
			NGUITools.PlaySound(thisScript.soundChangeMoney);
		}
	}

	public static void setNewName(string name)
	{
		tekName = RemoveBbcode(name);
		BCWStorage.Set(keyCryptoName, tekName);
		if (BCWServer.instance != null)
		{
			BCWServer.instance.UpdatePlayerData();
		}
	}

	public static string RemoveBbcode(string str)
	{
		string input = str;
		string pattern = "\\[-\\]";
		input = Regex.Replace(input, pattern, string.Empty);
		pattern = "\\[[0-9a-fA-F]{6}\\]";
		input = Regex.Replace(input, pattern, string.Empty);
		pattern = "\\[[0-9a-fA-F]{8}\\]";
		return Regex.Replace(input, pattern, string.Empty);
	}

	public static void playSoundButton()
	{
	}

	public static void updateKolDead(int newKol)
	{
		tekKolDead = newKol;
		Save.SaveInt(keyKolDead, tekKolDead);
	}

	public static void updateKolKill(int newKol)
	{
		tekKolKillPVE = newKol;
		Save.SaveInt(keyKolKill, tekKolKillPVE);
	}

	public static void updateKolKillPVP(int tekKolPoints)
	{
		tekKolKillPVP += tekKolPoints;
		Save.SaveInt(keyKolMaxPoints, tekKolKillPVP);
	}

	public static string GetRoundCountKeyForGameMode(TypeGame typeGame)
	{
		string text = typeGame.ToString();
		switch (typeGame)
		{
		case TypeGame.race:
		case TypeGame.RocketLeague:
			text = "CarsMode";
			break;
		case TypeGame.WalkingRobots:
		case TypeGame.TitanfallV2:
			text = "TitansMode";
			break;
		}
		return text + "_roundsCount";
	}

	public static void IncreaseRoundCountForGameMode(TypeGame typeGame, int addCount)
	{
		string roundCountKeyForGameMode = GetRoundCountKeyForGameMode(typeGame);
		int num = BCWStorage.Get<int>(roundCountKeyForGameMode);
		BCWStorage.Set(roundCountKeyForGameMode, num + addCount, true);
	}

	public static int GetRoundCountForGameMode(TypeGame typeGame)
	{
		string roundCountKeyForGameMode = GetRoundCountKeyForGameMode(typeGame);
		return BCWStorage.Get<int>(roundCountKeyForGameMode);
	}

	public static Texture2D getTekSkin()
	{
		string text = "Skins/shablon_";
		text = ((tekNomSkin > 9) ? (text + tekNomSkin) : (text + "0" + tekNomSkin));
		return Resources.Load<Texture2D>(text);
	}

	public static Texture2D getTekSkin(int nomSkin)
	{
		return MarketController.Instance.GetSkinTexture("shablon_" + ((nomSkin <= 9) ? "0" : string.Empty) + nomSkin);
	}

	public static void getTekSkin(EnemyBehavior enamy, int nomSkin)
	{
		MarketController.Instance.SetEnemySkin(enamy, "shablon_" + ((nomSkin <= 9) ? "0" : string.Empty) + nomSkin);
	}

	public static void addConsumable(int count, string key, int max = 999)
	{
		SetConsumableCount(key, Mathf.Clamp(GetConsumableCount(key) + count, 0, max));
	}

	public static void LoadConsumable(string key)
	{
		CryptoPlayerPrefs.SetInt(keyCountItem + key, BCWStorage.Get<int>(keyCountItem + key));
	}

	public static int GetConsumableCount(string key)
	{
		return BCWStorage.Get<int>(keyCountItem + key);
	}

	public static void SetConsumableCount(string key, int count)
	{
		BCWStorage.Set(keyCountItem + key, count);
	}

	public static void addC4(int count)
	{
		if (!Load.LoadBool(keyBulletsSaved + keyBuyGunC4))
		{
			Save.SaveBool(keyBulletsSaved + keyBuyGunC4, true);
			Save.SaveInt(keyCountBullets + keyBuyGunC4, 0);
		}
		Save.SaveInt(keyCountBullets + keyBuyGunC4, Load.LoadInt(keyCountBullets + keyBuyGunC4) + count);
		BCWDebug.Log("addC4 = " + Load.LoadInt(keyCountBullets + keyBuyGunC4));
	}

	public static void addEasterGrenade(int count)
	{
		if (!Load.LoadBool(keyBulletsSaved + keyBuyEasterGrenade))
		{
			Save.SaveBool(keyBulletsSaved + keyBuyEasterGrenade, true);
			Save.SaveInt(keyCountBullets + keyBuyEasterGrenade, 0);
		}
		Save.SaveInt(keyCountBullets + keyBuyEasterGrenade, Load.LoadInt(keyCountBullets + keyBuyEasterGrenade) + count);
		BCWDebug.Log("addEasterGrenage = " + Load.LoadInt(keyCountBullets + keyBuyEasterGrenade));
	}

	public static void addEasterGrenade_v2(int count)
	{
		if (!Load.LoadBool(keyBulletsSaved + keyBuyEasterGrenade_v2))
		{
			Save.SaveBool(keyBulletsSaved + keyBuyEasterGrenade_v2, true);
			Save.SaveInt(keyCountBullets + keyBuyEasterGrenade_v2, 0);
		}
		Save.SaveInt(keyCountBullets + keyBuyEasterGrenade_v2, Load.LoadInt(keyCountBullets + keyBuyEasterGrenade_v2) + count);
		BCWDebug.Log("addEasterGrenage_v2 = " + Load.LoadInt(keyCountBullets + keyBuyEasterGrenade_v2));
	}

	public static void addMine(int count)
	{
		if (!Load.LoadBool(keyBulletsSaved + keyBuyGunMine))
		{
			Save.SaveBool(keyBulletsSaved + keyBuyGunMine, true);
			Save.SaveInt(keyCountBullets + keyBuyGunMine, 0);
		}
		Save.SaveInt(keyCountBullets + keyBuyGunMine, count);
		BCWDebug.Log("addMine = " + Load.LoadInt(keyCountBullets + keyBuyGunMine));
	}

	public static void updateArmorEnabled()
	{
		if (Load.LoadInt(keyArmor) > 0)
		{
			Save.SaveBool(keyArmorEnabled, true);
		}
		else
		{
			Save.SaveBool(keyArmorEnabled, false);
		}
	}

	private IEnumerator TestConnection()
	{
		float timeTaken2 = 0f;
		float maxTime = 1f;
		while (true)
		{
			Ping testPing = new Ping("Google.com");
			timeTaken2 = 0f;
			while (!testPing.isDone)
			{
				timeTaken2 += Time.deltaTime;
				if (timeTaken2 > maxTime)
				{
					isConnected = false;
					break;
				}
				yield return null;
			}
			if (timeTaken2 <= maxTime)
			{
				isConnected = true;
			}
			yield return null;
		}
	}

	private void OnApplicationPause(bool pauseStatus)
	{
		if (!seichasPokupaemInapi && pauseStatus)
		{
			if (PanelEndGameRewardUI.instance != null)
			{
				PanelEndGameRewardUI.instance.SaveRewardOnQuit();
			}
			SavePlayedTime();
			SaveCathedExeptionsToStorager();
			BCWStorage.SaveAll();
		}
	}

	private void SavePlayedTime()
	{
		double result;
		double.TryParse(BCWStorage.Get<string>("TotalTimePlayed"), out result);
		double num = result + (double)Time.time - savedPlayTime;
		savedPlayTime = Time.time;
		BCWStorage.Set("TotalTimePlayed", num.ToString());
	}

	private static byte[] GetHash()
	{
		AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
		AndroidJavaObject @static = androidJavaClass.GetStatic<AndroidJavaObject>("currentActivity");
		string text = @static.Call<string>("getPackageName", new object[0]) ?? string.Empty;
		AndroidJavaObject androidJavaObject = @static.Call<AndroidJavaObject>("getPackageManager", new object[0]);
		if (androidJavaObject == null)
		{
			throw new InvalidOperationException("getPackageManager() == null");
		}
		AndroidJavaObject androidJavaObject2 = androidJavaObject.Call<AndroidJavaObject>("getPackageInfo", new object[2] { text, 64 });
		if (androidJavaObject == null)
		{
			throw new InvalidOperationException("getPackageInfo() == null");
		}
		AndroidJavaObject[] array = androidJavaObject2.Get<AndroidJavaObject[]>("signatures");
		if (array == null)
		{
			throw new InvalidOperationException("signatures() == null");
		}
		byte[][] array2 = (from s in array
			select s.Call<byte[]>("toByteArray", new object[0]) into s
			where s != null
			select s).ToArray();
		SHA1Managed sHA1Managed = new SHA1Managed();
		return sHA1Managed.ComputeHash(array2[0]);
	}

	public static string LoadString(string value)
	{
		byte[] array = Convert.FromBase64String(value);
		byte[] bytes = Enumerable.Repeat(GetHash(), array.Length).SelectMany((byte[] bs) => bs).Take(array.Length)
			.ToArray();
		byte[] array2 = new byte[array.Length];
		new BitArray(array).Xor(new BitArray(bytes)).CopyTo(array2, 0);
		return Convert.ToBase64String(array2).Replace('+', '-');
	}
}
